package com.api.shopapi.service.impl;

import com.api.shopapi.entity.AccountingRecord;
import com.api.shopapi.entity.dto.AccountingRecordDTO;
import com.api.shopapi.mapper.AccountingRecordMapper;
import com.api.shopapi.service.AccountingRecordService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("AccountingRecordServiceImplOne")
public class AccountingRecordServiceImpl  implements AccountingRecordService {

    @Autowired
    private AccountingRecordMapper accountingRecordMapper;

    @Override
    public int insert(AccountingRecord accountingRecord) {
        return accountingRecordMapper.insert(accountingRecord);
    }

    @Override
    public int update(AccountingRecord accountingRecord) {
        return accountingRecordMapper.update(accountingRecord);
    }

    @Override
    public int delete(String accountingRecordCode) {
        return accountingRecordMapper.delete(accountingRecordCode);
    }

    @Override
    public AccountingRecord getByAccountingRecordCode(String accountingRecordCode) {
        return accountingRecordMapper.getByAccountingRecordCode(accountingRecordCode);
    }

    @Override
    public PageInfo<AccountingRecordDTO> getPage(int pageIndex, int pageSize, String businessCode, String startTime, String endTime, int status) {
        PageHelper.startPage(pageIndex,pageSize);
        List<AccountingRecordDTO> accountingRecordList = accountingRecordMapper.getPage(businessCode,startTime,endTime,status);
        return new PageInfo<>(accountingRecordList);
    }
}
